<?

if ($DATA['component']['id']) {
	
	$_plugin = 'Articles';
	$_table = 'data';				// where info is stored

	$_record = array('id_data' => D_MB_SETTINGS, 'id_parent' => $DATA['component']['id'], 'assoc' => '');

	$_fields = array(
		'catalogs' => '', 
		'num' => 1, 
		'order' => 0, 
		'tn_sized' => 0, 
		'tnx' => 0, 
		'tny' => 0,
		'show_tn' => 0, 
		'show_date' => 0, 
		'show_body' => 0, 
		'show_title' => 0, 
		'show_anons' => 0, 
		'show_type' => 0, 
		'hide_parametric' => '',
		'caption' => array('large' => true, 'lang' => true),
		'base' => array('lang' => true),
	);


	
	$_crit = "id_data=".D_MULTIBLOCK." AND  ".dbAndL('attr', COM_ENABLED)." AND INSTR(value,'$_plugin')!=0";	// data selection criterium


	$DATA['objects'] = datafetch_array('db_list', array('table' => tb($_table), 'where' => $_crit, 'index' => 'id' ));

	switch (action(array('editor_save'))) {
	
		case 'editor_save':

			$_POST['catalogs'] = implode(',', (array)postdata('catalogs'));
		
			dataset('killmeta', "(id_data=".D_MB_SETTINGS.") AND (id_parent={$DATA[component][id]})");
			dataset('savemeta', prepareModel($_fields, $_record));
			
			return true;	// end of component edition
	}
	
	$DATA['settings'] = array_merge($_fields, datafetch_array('loadmeta', D_MB_SETTINGS, 
		array('parent' => $DATA['component']['id'], 'getclob' => true)));
	
	$DATA['settings']['catalogs'] = (array)explode(',', $DATA['settings']['catalogs']);

	foreach($DATA['langs'] as $lang)
		$DATA['settings']['data'][$lang['text']] = datafetch_array('loadmeta', D_MB_SETTINGS, 
			array('parent' => $DATA['component']['id'], 'assoc' => $lang['text'], 'getclob' => true));
		
	return false;

} else exit;